From 8f79397a7cdd5cc4f7f91b43778a5eed5c51e4cb Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Fri, 12 Jun 2009 09:17:21 +0000 Subject: [PATCH] Fixes for r51774: * declare $ip and $ipchain so that it doesn't throw notices and warnings * don't set $ip to false after getting it from $_SERVER['REMOTE_ADDR'], otherwise it won't work when there's no XFF header * fix logic when throwing the exception: throw it when there's no IP --- includes/ProxyTools.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/ProxyTools.php b/includes/ProxyTools.php index dc30d0ef30..fe31376eb6 100644 --- a/includes/ProxyTools.php +++ b/includes/ProxyTools.php @@ -74,6 +74,9 @@ function wfGetIP() { return $wgIP; } + $ipchain = array(); + $ip = false; + /* collect the originating ips */ # Client connecting to this webserver if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { @@ -82,8 +85,6 @@ function wfGetIP() { if( $ip ) { $ipchain[] = $ip; } - - $ip = false; # Append XFF on to $ipchain $forwardedFor = wfGetForwardedFor(); @@ -108,7 +109,7 @@ function wfGetIP() { } } - if( $ip ) { + if( !$ip ) { throw new MWException( "Unable to determine IP" ); } -- 2.20.1